import { createApp } from 'vue'
import './style.css'
// el plus
// import ElementPlus from 'element-plus'
// import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// import { ElMessage } from 'element-plus'
// import { ElNotification } from 'element-plus'
// router
import router from "./router/index"
// windicss
import 'virtual:windi.css'
// pinia
import {createPinia} from 'pinia'
// import piniaPluginPersist from 'pinia-plugin-persist' // 这个很坑，下面这个好用
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate' //引入pinia persist数据持久化插件

// axios请求
// import { request } from '@/services/request'

// 导入methods
import methods from '@/utils/methods'

// 进度条
// import nProgress from 'nprogress'
// import 'nprogress/nprogress.css'

import App from './App.vue'

const app = createApp(App)

// 全局挂载
// app.config.globalProperties.$axios = request
app.config.globalProperties.$message = ElMessage
// app.config.globalProperties.$messageNotion = ElNotification
type Methods = {
  [proName: string]: Function
}
Object.keys(methods).forEach(k => {
  app.config.globalProperties[`$${k}`] =  (methods as Methods)[k]
})

// roter
app.use(router)
// el
// app.use(ElementPlus)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
// pinia
// app.use(createPinia().use(piniaPluginPersist))  //安装插件
app.use(createPinia().use(piniaPluginPersistedstate))  //安装插件

app.mount('#app')
